parser grammar SyntaxParser;

options {
  tokenVocab = SyntaxLexer;
}

file                    : (dataDescription | line)* EOF
                        ;                        
dataDescription         : levelNum (データ名 | KW_FILLER)
                          (((KW_PIC | KW_PICTURE) (KW_IS)? PicString)
                           | word)*
                          //DOT
                          EOL
                        ;
levelNum                : IntegerLiteral
                        ;
データ名                : Identifier
                        ;
execStmt                : KW_EXEC
                          wordList
                          KW_END_EXEC
                          EOL
                        ;
//----------------------------------------------------------------------------
// line
//----------------------------------------------------------------------------                       
line                    : wordList EOL
                        ;
//キー区分(tblSyntax.KeyKBN) = 2:可変部分
wordList                : (word)*
                        ;
//キー区分(tblSyntax.KeyKBN) = 6:単語の可変部分 
word                    : ~EOL //EOL以外のtoken
                        ;
//----------------------------------------------------------------------------
// Literal
//----------------------------------------------------------------------------
literal                 : numericLiteral
                        | nonnumericLiteral
                        ;
//キー区分(tblSyntax.KeyKBN) = 14:数字単語 
numericLiteral          : DecimalLiteral
                        | IntegerLiteral
                        ;
//キー区分(tblSyntax.KeyKBN) = 22:非数字単語 
nonnumericLiteral       : StringLiteral
                        | DbcsLiteral
                        | Utf8Literal
                        | HexNumber
                        | NullTerminated
                        ;
//----------------------------------------------------------------------------
// keyword
//----------------------------------------------------------------------------
//キー区分(tblSyntax.KeyKBN) = 0:ｷｰﾜｰﾄﾞ 
keyword                 : KW_ACCEPT
                        | KW_ACCESS
                        | KW_ADD
                        | KW_ADDRESS
                        | KW_ADVANCING
                        | KW_AFTER
                        | KW_ASCENDING
                        | KW_ALL
                        | KW_ALLOCATE
                        | KW_ALPHABET
                        | KW_ALPHABETIC
                        | KW_ALPHABETIC_LOWER
                        | KW_ALPHABETIC_UPPER
                        | KW_ALSO
                        | KW_ALTER
                        | KW_ALTERNATE
                        | KW_AND
                        | KW_ANY
                        | KW_APPLY
                        | KW_ARE
                        | KW_AREA
                        | KW_AREAS
                        | KW_ASSIGN
                        | KW_AS
                        | KW_AT
                        | KW_ATTRIBUTE
                        | KW_ATTRIBUTES
                        | KW_BEFORE
                        | KW_BINARY
                        | KW_BLANK
                        | KW_BLOCK
                        | KW_BOOL
                        | KW_BOOLEAN
                        | KW_BOTTOM
                        | KW_BY
                        | KW_BYTE_LENGTH
                        | KW_CALL
                        | KW_CANCEL
                        | KW_CHARACTER
                        | KW_CHARACTERS
                        | KW_CICS
                        | KW_CLASS
                        | KW_CLASS_ID
                        | KW_CLOSE
                        | KW_COBOL
                        | KW_CODE_SET
                        | KW_COLLATING
                        | KW_COMMA
                        | KW_COMMON
                        | KW_COMP
                        | KW_COMP_1
                        | KW_COMP_2
                        | KW_COMP_3
                        | KW_COMP_4
                        | KW_COMP_5
                        | KW_COMPUTATIONAL
                        | KW_COMPUTATIONAL_1
                        | KW_COMPUTATIONAL_2
                        | KW_COMPUTATIONAL_3
                        | KW_COMPUTATIONAL_4
                        | KW_COMPUTATIONAL_5
                        | KW_COMPUTE
                        | KW_CONFIGURATION
                        | KW_CONTAINS
                        | KW_CONTENT
                        | KW_CONTINUE
                        | KW_CONVERTING
                        | KW_CORR
                        | KW_CORRESPONDING
                        | KW_COUNT
                        | KW_CURRENCY
                        | KW_CYCLE
                        | KW_DATA
                        | KW_DATE
                        | KW_DAY
                        | KW_DAY_OF_WEEK
                        | KW_DBCS
                        | KW_DEBUGGING
                        | KW_DECIMAL_POINT
                        | KW_DECLARATIVE
                        | KW_DECLARATIVES
                        | KW_DEFAULT
                        | KW_DELETE
                        | KW_DELIMITED
                        | KW_DELIMITER
                        | KW_DEPENDING
                        | KW_DESCENDING
                        | KW_DETAIL
                        | KW_DISPLAY
                        | KW_DISPLAY_1
                        | KW_DIVIDE
                        | KW_DIVISION
                        | KW_DOWN
                        | KW_DUPLICATES
                        | KW_DYNAMIC
                        | KW_EBCDIC
                        | KW_ELEMENT
                        | KW_ELSE
                        | KW_END
                        | KW_END_ADD
                        | KW_END_CALL
                        | KW_END_COMPUTE
                        | KW_END_DELETE
                        | KW_END_DIVIDE
                        | KW_END_EVALUATE
                        | KW_END_EXEC
                        | KW_END_IF
                        | KW_END_INVOKE
                        | KW_END_JSON
                        | KW_END_MULTIPLY
                        | KW_END_OF_PAGE
                        | KW_END_PERFORM
                        | KW_END_READ
                        | KW_END_RETURN
                        | KW_END_REWRITE
                        | KW_END_SEARCH
                        | KW_END_START
                        | KW_END_STRING
                        | KW_END_SUBTRACT
                        | KW_END_UNSTRING
                        | KW_END_WRITE
                        | KW_END_XML
                        | KW_ENTRY
                        | KW_ENVIRONMENT
                        | KW_EQUAL
                        | KW_EOP
                        | KW_ERROR
                        | KW_EVALUATE
                        | KW_EVERY
                        | KW_EXCEPTION
                        | KW_EXEC
                        | KW_EXIT
                        | KW_EXTEND
                        | KW_EXTERNAL
                        | KW_FACTORY
                        | KW_FALSE
                        | KW_FD
                        | KW_FILE
                        | KW_FILE_CONTROL
                        | KW_FILLER
                        | KW_FIRST
                        | KW_FIXED
                        | KW_FOR
                        | KW_FOOTING
                        | KW_FREE
                        | KW_FROM
                        | KW_FUNCTION
                        | KW_FUNCTION_POINTER
                        | KW_GENERATE
                        | KW_GLOBAL
                        | KW_GIVING
                        | KW_GO
                        | KW_GOBACK
                        | KW_GREATER
                        | KW_GROUP_USAGE
                        | KW_HIGH_VALUE
                        | KW_HIGH_VALUES
                        | KW_ID
                        | KW_IDENTIFICATION
                        | KW_IF
                        | KW_IN
                        | KW_INDEX
                        | KW_INDEXED
                        | KW_INHERITS
                        | KW_INITIAL
                        | KW_INITIALIZE
                        | KW_INITIALIZED
                        | KW_INPUT
                        | KW_INPUT_OUTPUT
                        | KW_INSPECT
                        | KW_INTO
                        | KW_INTRINSIC
                        | KW_INVALID
                        | KW_INVOKE
                        | KW_I_O
                        | KW_I_O_CONTROL
                        | KW_IS
                        | KW_JSON
                        | KW_JUST
                        | KW_JUSTIFIED
                        | KW_KANJI
                        | KW_KEY
                        | KW_LABEL
                        | KW_LEADING
                        | KW_LEFT
                        | KW_LENGTH
                        | KW_LESS
                        | KW_LIMIT
                        | KW_LINAGE
                        | KW_LINE
                        | KW_LINES
                        | KW_LINKAGE
                        | KW_LOC
                        | KW_LOCK
                        | KW_LOCAL_STORAGE
                        | KW_LOW_VALUE
                        | KW_LOW_VALUES
                        | KW_MEMORY
                        | KW_MERGE
                        | KW_METHOD
                        | KW_METHOD_ID
                        | KW_MODE
                        | KW_MODULES
                        | KW_MOVE
                        | KW_MULTIPLE
                        | KW_MULTIPLY
                        | KW_NAME
                        | KW_NAMESPACE
                        | KW_NAMESPACE_PREFIX
                        | KW_NATIVE
                        | KW_NATIONAL
                        | KW_NEGATIVE
                        | KW_NEW
                        | KW_NEXT
                        | KW_NO
                        | KW_NOT
                        | KW_NUMERIC
                        | KW_NONNUMERIC
                        | KW_NULL
                        | KW_NULLS
                        | KW_OBJECT
                        | KW_OBJECT_COMPUTER
                        | KW_OCCURS
                        | KW_OUTPUT
                        | KW_OF
                        | KW_OFF
                        | KW_ON
                        | KW_OMITTED
                        | KW_OPEN
                        | KW_OR
                        | KW_ORDER
                        | KW_ORGANIZATION
                        | KW_OPTIONAL
                        | KW_OTHER
                        | KW_OVERFLOW
                        | KW_PACKED_DECIMAL
                        | KW_PADDING
                        | KW_PAGE
                        | KW_PARAGRAPH
                        | KW_PARSE
                        | KW_PASSWORD
                        | KW_PERFORM
                        | KW_PIC
                        | KW_PICTURE
                        | KW_POINTER
                        | KW_POINTER_32
                        | KW_POSITION
                        | KW_POSITIVE
                        | KW_PROCEDURE
                        | KW_PROCEDURE_POINTER
                        | KW_PROCEDURES
                        | KW_PROCEED
                        | KW_PROCESSING
                        | KW_PROGRAM
                        | KW_PROGRAM_ID
                        | KW_RANDOM
                        | KW_READ
                        | KW_RECORD
                        | KW_RECORDING
                        | KW_RECORDS
                        | KW_RECURSIVE
                        | KW_REDEFINES
                        | KW_REEL
                        | KW_REFERENCE
                        | KW_RELATIVE
                        | KW_RELEASE
                        | KW_REMAINDER
                        | KW_REMOVAL
                        | KW_RENAMES
                        | KW_RERUN
                        | KW_RETURN
                        | KW_REPLACING
                        | KW_REPOSITORY
                        | KW_RESERVE
                        | KW_RETURNING
                        | KW_REVERSED
                        | KW_REWIND
                        | KW_REWRITE
                        | KW_RIGHT
                        | KW_ROUNDED
                        | KW_RUN
                        | KW_SD
                        | KW_SAME
                        | KW_SEARCH
                        | KW_SECTION
                        | KW_SEGMENT_LIMIT
                        | KW_SELECT
                        | KW_SELF
                        | KW_SENTENCE
                        | KW_SEPARATE
                        | KW_SEQUENCE
                        | KW_SEQUENTIAL
                        | KW_SET
                        | KW_SIGN
                        | KW_SIZE
                        | KW_SORT
                        | KW_SORT_MERGE
                        | KW_SOURCE_COMPUTER
                        | KW_SPACE
                        | KW_SPACES
                        | KW_SPECIAL_NAMES
                        | KW_SQL
                        | KW_SQLIMS
                        | KW_STANDARD
                        | KW_STANDARD_1
                        | KW_STANDARD_2
                        | KW_START
                        | KW_STATUS
                        | KW_STOP
                        | KW_STRING
                        | KW_SUBTRACT
                        | KW_SUPER
                        | KW_SUPPRESS
                        | KW_SYMBOL
                        | KW_SYMBOLIC
                        | KW_SYNC
                        | KW_SYNCHRONIZED
                        | KW_TALLYING
                        | KW_TAPE
                        | KW_TEST
                        | KW_THAN
                        | KW_THEN
                        | KW_THROUGH
                        | KW_THRU
                        | KW_TIME
                        | KW_TIMES
                        | KW_TO
                        | KW_TOP
                        | KW_TRAILING
                        | KW_TRUE
                        | KW_TYPE
                        | KW_UNIT
                        | KW_UNBOUNDED
                        | KW_UNTIL
                        | KW_UNSTRING
                        | KW_UP
                        | KW_UPON
                        | KW_USAGE
                        | KW_USE
                        | KW_USING
                        | KW_UTF_8
                        | KW_VALIDATING
                        | KW_VALUE
                        | KW_VARYING
                        | KW_VOLATILE
                        | KW_WHEN
                        | KW_WITH
                        | KW_WRITE
                        | KW_WRITE_ONLY
                        | KW_WORDS
                        | KW_WORKING_STORAGE
                        | KW_XML
                        | KW_XML_SCHEMA
                        | KW_XML_DECLARATION
                        | KW_YYYYDDD
                        | KW_YYYYMMDD
                        | KW_ZERO
                        | KW_ZEROES
                        | KW_ZEROS
                        ;